<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/WEB-INF/jsppages/include/taglibs.jsp"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<title><%=system_name%> - 物料清单管理</title>
	<base href="<%=basePath%>" />	
 	<meta http-equiv="pragma" content="no-cache" />
 	<meta http-equiv="cache-control" content="no-cache" />
	<meta http-equiv="expires" content="0" />
	<link type="image/x-icon" rel="shortcut icon" href="<%=basePath%>images/favicon.ico" />
	<link href="css/style.css" rel="stylesheet" type="text/css" />
	<link href="<%=basePath%>css/common.css" rel="stylesheet" type="text/css" />
	<link href="<%=basePath%>css/userlist.css" rel="stylesheet" type="text/css" />
	<script src="<%=basePath%>js/common.js" type="text/javascript"></script>
	<script type="text/javascript" src="js/pagebar_cn.js"></script>
	<script type="text/javascript" src="fram/engine.js" ></script>
	<script type="text/javascript" src="fram/util.js" ></script>
	<script type="text/javascript" src="fram/interface/shipService.js"></script>
	<script type="text/javascript" src="<%=basePath%>js/DatePicker/WdatePicker.js" defer="defer"></script>	 
</head>

<body oncontextmenu='return false'>

<!--top begin-->
	<%@include file="/WEB-INF/jsppages/admin/head.jsp"%>
	<!--top end-->


<div class="wrap100 content">

    <!--left begin-->
	<%@include file="/WEB-INF/jsppages/admin/left.jsp"%>
    <!--left end-->    
    
    <!--right begin-->
<div class="right">
            <div class="search">
                <form action="<%=basePath%>trade/shipMaterialList" method="GET">
                <table width="100%" border="0" cellspacing="0" cellpadding="5">
                  <tr>
                    <td width="5%"><img src="images/marking1.gif" width="41" height="44" alt="marking" /></td>
                    <td width="8%">快速查询</td>
                    <td width="25%">材料编码：<input type="text" name="code" value="${shipMaterialSearchCond.code}" style="width:100px;" />
                    </td>
                    <td width="20%">材料名称：<input type="text" name="name" value="${shipMaterialSearchCond.name}" style="width:100px;" /></td></td>
                    <td width="11%">
                    <input type="submit" style="background:url(images/searchBtn.gif);width:116px;height:30px;border:0;margin:0;" value="" />
                    </td>
                    <td width="30%">
                    <jsp:useBean id="nowDate" class="java.util.Date"></jsp:useBean>
   					 现在是：${formatDate}<fmt:formatDate value="${nowDate}" type="both" dateStyle="full"/>
   					</td>
                    <td width="1%">&nbsp;</td>
                  </tr>
                </table>    
                </form>
        </div>
            <table width="100%" border="0" cellspacing="0" cellpadding="0">
                  <tr>
                    <td height="60"><h1>物料清单管理</h1></td>
              </tr>
            </table>
                
      
    <div class="rightContentTop">
        <div class="subMenu">
          <ul>
            <li><a href="#" class="current">物料清单列表</a></li>
          </ul>
      </div>
        </div>
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td align="right"><span style="float:left;color:#666;">共找到<font color="red"> ${searchStat.totalCount} </font>条记录</span>
                <c:if test="${sessionScope.memberSessionInfo.userType.value<2}">
                <a href="javascript:;" onclick="addShipMaterial()" style="font-weight:bold"><img src="images/add.gif" width="90" height="31" alt="添加" /></a>
                <!-- <a href="#"><img src="images/del.gif" width="90" height="31" alt="删除" /></a> -->
                </c:if>
                </td>
              </tr>
    	</table>
		
        <div class="rightContent1">

            <table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr class="td">
                <th width="4%" align="center" bgcolor="#f9f9f9"><input type="checkbox" name="checkbox4" id="checkbox4" /></th>
                <th width="10%" align="center" bgcolor="#f9f9f9">材料编码</th>
                <th width="26%" align="center" bgcolor="#f9f9f9">材料名称</th>
                <th width="20%" align="center" bgcolor="#f9f9f9">规格型号</th>
                <th width="20%" align="center" bgcolor="#f9f9f9">主计量单位</th>
                <th width="20%" align="center" bgcolor="#f9f9f9">操作</th>
              </tr>
              <c:forEach var="shipMaterial" items="${shipMaterialList}">
              <tr>
                <td align="center"><input type="checkbox" name="checkbox" id="checkbox" value="${shipMaterial.id}"/></td>
                <td align="center">${shipMaterial.code}</td>
                <td align="center">${shipMaterial.name}</td>
                <td align="center">${shipMaterial.format}</td>
                <td>${shipMaterial.unit}</td>
                <td align="left">
                	<c:if test="${sessionScope.memberSessionInfo.userType.value<2}">
              		<a href="javascript:;" onclick="delShipMaterial('${shipMaterial.id}')"><img src="images/del1.jpg" alt="删除" /></a>
                	<a href="javascript:;" onclick="editShipMaterial('${shipMaterial.id}')"><img src="images/modify.jpg" alt="修改" /></a>
                	</c:if>
              </td>
              </tr>
              </c:forEach>
			<c:if test="${empty shipMaterialList}"><tr><td colspan="16" style="text-align:center">没有相关记录！</td></tr></c:if>
            </table>
		</div>
		<!-- 
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td><a href="zmateAdd.htm"><br />
            </a>　<a href="#"><img src="images/del.gif" width="90" height="31" alt="删除" /></a></td>
          </tr>
        </table> -->
         <script type="text/javascript">
		var pageControl = new wpagebar('pageControl');
		pageControl.argName = "pageIndex";
		pageControl.pageCount =${searchStat.pageCount};
		pageControl.load();		
  	   </script>     
  	   
  	   <div id="win_temp" style="display:none">
	<div id="winCon_1">
	<table class="tabView" style="margin-top:5px">
		<tr><th width="100">材料编码：</th><td>
		<input type="text" name="code0" id="code0" value="" />
		<input type="text" name="shipMaterialId0" id="shipMaterialId0" style="display:none"/></td></tr>
		<tr><th>材料名称：</th><td><input type="text" name="name0" id="name0" value="" /></td></tr>
		<tr><th>规格型号：</th><td><input type="text" id="format0" name="format0" value="" /></td></tr>
		<tr><th>主计量单位：</th><td><input type="text" id="unit0" name="unit0" value="" /></td></tr>
		<tr><td colspan="2" style="text-align:center;height:">
		<input type="button" value=" 提 交 " class="btn1" onclick="submitShipMaterial()"/></td></tr>
	</table>
	</div>
	
	</div>
    <script src="<%=basePath%>js/win.js" type="text/javascript"></script>
</div>
<script  type="text/javascript">
function addShipMaterial(){
	WIN.show('添加物料清单信息',$('winCon_1'),{height:100});
}
function editShipMaterial(id){
	WIN.show('修改物料清单信息',$('winCon_1'),{height:350});
	shipService.getShipMaterialById(id,function(data){
		$('shipMaterialId0').value=data.id;
		$('code0').value=data.code;
		$('name0').value=data.name;
		$('format0').value=data.format;
		$('unit0').value=data.unit;				
	})
}
function delShipMaterial(id){
	if(confirm("删除物料清单信息，确定删除 ？")){
		WIN.showpg();
		shipService.delShipMaterialById(id,{
			callback:function(f){WIN.closepg();alert("删除成功");reload();},
			exceptionHandler:function(message){WIN.closepg();alert("删除失败，请重试");},
			errorHander:function(err){}
		})
	}
}
/**/
function submitShipMaterial(){
	var shipMaterial={
			id:		$('shipMaterialId0').value,			
			code:	$('code0').value,
			name:	$('name0').value,
			format: $('format0').value,
			unit:	$('unit0').value,			
	}	
	if(''==shipMaterial.code){alert('材料编码不能为空');return;}
	if(''==shipMaterial.name){alert('材料名称不能为空');return;}
	submit(shipMaterial);	
}
function submit(log){
	WIN.close();
	WIN.showpg();
	shipService.editShipMaterial(log,{
		callback:function(f){WIN.closepg();alert("操作成功");reload();},
		exceptionHandler:function(message){WIN.closepg();alert(message);alert("操作失败，请重试");},
		errorHander:function(err){}
	})
}

</script>
</body>
</html>
